import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;


public class GeneradorDeCasos {
		
	
	public static void main(String[] args) {
		
		
		//Completos
		/*
		ArrayList<ArrayList<ArrayList<Integer>>> matrices  = new ArrayList<ArrayList<ArrayList<Integer>>>();
		matrices.add(generarCompleto(10));
		matrices.add(generarCompleto(15));
		matrices.add(generarCompleto(20));
		
		try {
			generarOut(matrices, "");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		//completos
		ArrayList<ArrayList<ArrayList<Integer>>> matrices  = new ArrayList<ArrayList<ArrayList<Integer>>>();
		int i = 1024;
		for (int j = 1; j < i; j=j*2) {			
			matrices.add(generarIncompleto(j));
		}
		
		try {
			generarOut(matrices, "");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	
	
	
	
	/**
	 * Genera un completo de n nodos, ordenado
	 * @param n
	 */
	public static ArrayList<ArrayList<Integer>> generarCompleto(int n){
		ArrayList<ArrayList<Integer>> matriz = new ArrayList<ArrayList<Integer>>();
		
		for (int i = 1; i <= n; i++) {
			ArrayList<Integer> arrayList = new ArrayList<Integer>();
			for (int j = 1; j <= n; j++) {
				if(j!=i){
					arrayList.add(j);
				}
			}
			matriz.add(arrayList);
		}
		
		return matriz;
	}
	
	public static ArrayList<ArrayList<Integer>> generarIncompleto(int n){
		
		int [][] matrizAdy = new int[n][n];
		
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				boolean isRelated = (new Float(Math.random()*n)).intValue()%2 == 0;
				matrizAdy[i][j] = isRelated?1:0;
				matrizAdy[j][i] = isRelated?1:0;
			}
		}
		
		return Ejercicio3.getMatrizVecinos(matrizAdy);
		
		
	}
	
	
	public static void generarOut(ArrayList<ArrayList<ArrayList<Integer>>>casoPruebaMatrizVecinos,String name) throws IOException{
		BufferedWriter out = new BufferedWriter(new FileWriter("Tp2Ej3"+name+".in"));
		
		for (int i = 1; i <= casoPruebaMatrizVecinos.size(); i++) {
			
		ArrayList<ArrayList<Integer>> arrayList = casoPruebaMatrizVecinos.get(i-1);
		
			out.write(arrayList.size()+"");
			out.newLine();
			
			for (int j = 1; j <= arrayList.size(); j++) {
				
				ArrayList<Integer> arrayList2 = arrayList.get(j-1);
				
				out.write(arrayList2.size()+" ");
				
				for (Integer integer : arrayList2) {
					if(integer!=j){
						out.write(integer+" ");
					}
				}
				
				if(j< arrayList.size()){
					out.newLine();
				}
			}
			
			if(i <= casoPruebaMatrizVecinos.size()){
				out.newLine();
			}
		}
		
		out.write("-1");
		out.close();
	}
	
	
}
